import request from "@/utils/request"
import type { AttrInfoModel, AttrListModel } from "./model/attrModel"
import type { CategoryIdsModel } from "./model/categoryModel"

enum Api {
  attrInfoListApi = "/admin/product/attrInfoList",
  deleteAttrInfoApi = "/admin/product/deleteAttr",
  addOrUpdateAttrInfoApi = "/admin/product/saveAttrInfo",
}

export const reqGetAttrInfoList = ({
  category1Id,
  category2Id,
  category3Id,
}: CategoryIdsModel) =>
  request.get<any, AttrListModel>(
    Api.attrInfoListApi + `/${category1Id}/${category2Id}/${category3Id}`
  )

export const reqDeleteAttrInfo = (attrId: number) =>
  request.delete<any, null>(Api.deleteAttrInfoApi + `/${attrId}`)

export const reqAddOrUpdateAttrInfo = (attrInfo: AttrInfoModel) =>
  request.post<any, null>(Api.addOrUpdateAttrInfoApi, attrInfo)
